@envs = grep(!/$env/,@envs); $fakeenv_rx = "\(".join("|",@envs)."\)"; else { print OUT $line; elsif (! $mute) { # print line if in verbatim/comment mode print OUT $line; return(1); #continue if not $end_document sub process_input_include_file { local($_) = @_; local($before,$after,$class,$styles); $_ =~ s/\n$//; print STDERR "$prompt %— Found include at level $includelevel: $_" if($debug); # Get filename local($filename) = ""; # $class serves as temporary storage if (/(\\input|\\include)\s*$arg_rx/o) { ($before,$after,$class,$filename) = ($‘, $’, $&, $2); $filename =~ s/\s//g; elsif (/(\\input|\\include)\s+(\S+)(?=\s|$)/o) { ($before,$after,$class,$filename) = ($‘, $’, $&, $2); $filename =~ s/\s//g; else { print STDERR "$prompt %— COULDN’T FIND FILENAME\n" if($debug); if ($filename) { # Get base name $styles = $filename; $styles =~ s|.*\Q$dd\E||; # strip path $styles =~ s/\.[^.]*$//; # strip extension # Sorry for the next if-statement... (hmm,ok) if ($styles !~ /^($do_include_rx)$/o && $filename !~ /\.($do_include_ext_rx)$/o && ($styles =~ /^($dont_include_rx)$/o || ($opt{auto_exclude && $filename =~ /\.($dont_include_ext_rx)$/o))) { print STDERR "$prompt %— ignoring $filename" if($debug); print STYLES "$styles\n" if($opt{save_styles); else { local($fname) = &find_file($filename); # notify anyway that a file is found, to allow a Perl # module loaded for this specific file # print STYLES "$styles\n" if($opt{save_styles); if($fname) { print OUT "$before"; # recursive call &process_file($fname); print OUT $after if($after =~ /\S+/); print STDERR "$prompt %— successfully included $filename" if($debug > 1); return(1); #merge else { print STDERR "$prompt include $filename failed. Reinserting $before command\n"; return(0); #no merge sub process_document_header { local($_) = @_; local(%style_include,@print_styles,$key,$isclass); local($before, $latextype, $styles, $class, $after); if(/\\document(class|style)\s*$options_rx\s*$arg_rx/o) { ($before, $latextype, $styles, $class, $after) = ($‘, $1, $2 || ”, $3, $’); if ($latextype =~ /class/) { $isclass = 1; else { print OUT $_; return; $_ =~ s/\n$//; print STDERR "$prompt %— Found $latextype: $_\n" if($debug); $styles =~ s/\[(.*)\]/$1/; # Strip braces $class =~ s/\s//g; # Strip spaces # the class cannot be included, so stuff it in the style file print STYLES "$class".($isclass ? ”:"\n") if($opt{save_styles); foreach $key (split(/,/, $styles)) { $key =~ s/\s//g; # strip spaces push(@print_styles,$key); if (&should_include($key)) { # mark the style for inclusion and search for the # corresponding .clo (LaTeX2e) or .sty (LaTeX209) # &find_file gives the filename or undef. $style_include{$key = &find_file($key . (($latextype =~ /class/) ? ’.clo’ : ’.sty’)); $styles = ”; foreach $key (@print_styles) { if(!$style_include{$key) { # put style back into command and save it to the style file print STYLES ($isclass ? " $key," : "$key\n") if($opt{save_styles); $styles .= ’,’ . $key; if ($styles) { $styles =~ s/^,//; $styles = ’[’ . $styles . ’]’; print OUT join(”, $before, "\\document", $latextype, $styles, ’{’, $class, ’’, $after); # Include styles after the \document(class|style) command foreach $key (@print_styles) { if($style_include{$key) { &process_file($style_include{$key); print STYLES "\n" if($opt{save_styles && $isclass); sub process_package_cmd { local($_) = @_; local(%style_include,@print_styles,$key); /\\(usepackage|RequirePackage)\s*$options_rx\s*$arg_rx/o; local ($before,$class,$options,$styles,$after) = ($‘, $1, $2 || ”, $3, $’); print STDERR "$prompt %— Found \\$class: $_" if($debug > 1); $options =~ s/\[(.*)\]/$1/o; # strip braces foreach $key (split(/,/,$styles)) { $key =~ s/\s//g; # strip spaces # Remember each package and check whether to merge it push(@print_styles,$key); if (&should_include($key)) { $style_include{$key=&find_file($key . ’.sty’); $styles = ”; foreach $key (@print_styles) { if (!$style_include{$key) { # print to style file and reinsert into command # if package is not to be merged print STYLES "$key $options\n" if($opt{save_styles); $styles .= ’,’ . $key; if($styles) { # Reconstruct command $styles =~ s/^,//; $options = ’[’ . $options . ’]’ if($options =~ /\S+/); print OUT $before . ’\\’ . $class . $options . ’{’ . $styles . ’’ . $after; else { print OUT $before . $after; foreach $key (@print_styles) { if($style_include{$key) { # merge style files &process_file($style_include{$key); sub process_dont_include { my @items = @_; my $item; foreach $item (@items) { if($item =~ s/^\.//) { # starts with ‘.’? Then it’s an extension $dont_include_ext_rx .= "|\Q$item\E"; else { push(@dont_include,$item); 1; sub process_do_include { my @items = @_; my $item; foreach $item (@items) { if($item =~ s/^\.//) { # starts with ‘.’? Then it’s an extension $do_include_ext_rx .= (($do_include_ext_rx eq ”) ? ” : ’|’) . "\Q$item\E"; else { push(@do_include,$item); 1; # Returns true if style has to be included, i.e.: # 1. The style is found in do_include *or* # 2. Automatic exclusion is disabled and the style is *not* found in # dont_include sub should_include { my ($style) = @_; return($style =~ /^($do_include_rx)$/o || (!$opt{auto_exclude && $style !~ /^($dont_include_rx)$/o )); sub find_file { local($file) = @_; local($fname,$dname); local($found)=0; print STDERR "$prompt %— checking for $file" if($debug); # if ($file =~ m|^$dd|) { if (L2hos->is_absolute_path($file)) { $fname=$file; if(&file_or_ext) { $found=1; else { if ($Web2C) { $file =~ s/\s+//g; if ($file =~ s/\.([^\.]+)\Z//) { @ext = ($1); else { @ext = (’tex’, ’ltx’, ’sty’); foreach $ext (@ext) { chop($fname = ‘kpsewhich -format=.tex $file.$ext‘); #RRM: I cannot make this work, to replace the ‘...‘ in the line above # $fname = &syswait("kpsewhich -format=.tex $file.$ext"); # chop $fname; print STDERR "$prompt kpsewhich says : $fname" if $debug; $found = 1; last; else { # search input directories foreach $dir (@texinputs) { ($dname = $dir) =~ s|[\Q$dd\E]+$||; # Remove slashes at the end if (-d $dname) { if ($fname = &dir_search($dir,$file)) { $found = 1; last; else { print STDERR "$prompt %— Warning: \"$dname\" is no directory" if ($debug); if ($found) { print STDERR "$prompt %— found $fname" if ($debug); return($fname); else { print STDERR "$prompt %— file not found" if ($debug); return(undef); sub dir_search { # search directory recursively local($dir,$file) = @_; local(*SUBDIR); # make file pointer local local($dname,$found,$recursive) =(”,0,0); if ($dir =~ m|\Q$dd$dd\E$|) { # does dir end in ‘//’? $recursive = 1; $dir =~ s|[\Q$dd\E]+$||; # Remove any slashes at the end local($fname) = join ($dd, $dir, $file); print STDERR "$prompt %— looking for $fname" if($debug); # Does file exist in this directory? if (&file_or_ext) { return($fname); elsif ($recursive) { # descend into subdirectories? # search directory for subdirectories opendir(SUBDIR,$dir); # open directory while (defined($_=readdir(SUBDIR))) { # read dir-entries next if(/^\./); # do not check dotfiles $dname = join ($dd, $dir, $_); if ((-d $dname) && ($fname = &dir_search($dname.$dd.$dd,$file))) { $found = 1; last; closedir(SUBDIR); if ($found) { return($fname); return(0); sub file_or_ext { # Modifies $fname # if $fname exists return success otherwise # if $fname.tex exists, then bind $fname to $fname.tex and return success # else fail return 1 if(!-d $fname && -r $fname); # && -s $fname; return 0 if $fname =~ /\.tex$/; $fname .= ".tex"; return 1 if -f $fname && -r $fname;# && -s $fname; return 0;


This document was generated on November 27, 2022 using texi2html 5.0.